package com.hnqcgczy.controller;

import com.hnqcgczy.service.IProductService;
import com.hnqcgczy.service.impl.ProductServiceImpl;
import com.hnqcgczy.vo.TProduct;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.List;

@WebServlet("/productList")
public class ProductListServlet extends HttpServlet {
    @Override
    protected void service(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        IProductService proService=new ProductServiceImpl();
        //接收服务层列表数据
        List<TProduct> prolist=proService.getProductList(8);
        //将数据存储于request作用域
        req.setAttribute("prolist",prolist);
        //转发到商品列表的jsp
        req.getRequestDispatcher("/productList.jsp").forward(req,resp);
    }
}
